package com.hzsai.rabbitmq;

import com.hzsai.pojo.User;
import com.hzsai.utils.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Service;

/**
 * hzsai 2019/8/1
 * usage:
 **/
@Slf4j
@Service
public class RabbitMQServiceImpl implements RabbitMQService{

    private static final Logger logger = LoggerFactory.getLogger(RabbitMQServiceImpl.class);

    @Value("${rabbitmq.queue.msg}")
    private String msgRouting = null;

    @Value("${rabbitmq.queue.user}")
    private String userRouting = null;

    @Autowired
    private RabbitTemplate template = null;

    @Override
    public void sendMsg(String msg) {
        template.convertAndSend(msgRouting, msg);
    }

    @Override
    public void sendUser(User user) {
        template.convertAndSend(userRouting, user);
    }
}
